package com.chen.paymentdemo.vo;

import lombok.Data;
import lombok.experimental.Accessors;

import java.util.HashMap;
import java.util.Map;

/**
 * @author Y·C
 * @version 1.0.0
 * @ClassName R.java
 * @Description TODO
 * @createTime 2023年07月19日 21:15:00
 */
@Data
@Accessors(chain = true)
public class R {
    private Integer code; //状态码
    private String msg; //消息
    private Map<String,Object> data = new HashMap<>(); //数据

    public static R ok(){
        R r = new R();
        r.setCode(200);
        r.setMsg("成功");
        return r;
    }

    public static R error(){
        R r = new R();
        r.setCode(500);
        r.setMsg("失败");
        return r;
    }

    public R code(Integer code){
        this.setCode(code);
        return this;
    }

    public R msg(String msg){
        this.setMsg(msg);
        return this;
    }

    public R data(String key,Object value){
        this.data.put(key,value);
        return this;
    }
}
